package cn.com.xf.service.impl;

import org.springframework.stereotype.Service;

import cn.com.xf.service.PushService;

@Service
public class PushServiceImpl implements PushService {

	public static final String APIKEY = "jaQYO2VUuiCPG4XxsDMmYnX4";
	public static final String SECRETKEY = "qnDmOvuQYVG2qkrWPGqfgxSoNETmlWv9";

	/**
	 * 推送通知
	 * 
	 * @param title
	 *            标题
	 * @param description
	 *            描述
	 * @param content
	 *            内容
	 * @throws PushClientException
	 * @throws PushServerException
	 */
	/*
	 * @Override public void pushNotificationToAll(String title,String content){
	 * 
	 * PushKeyPair pair = new PushKeyPair(APIKEY, SECRETKEY);
	 * 
	 * BaiduPushClient pushClient = new BaiduPushClient(pair,
	 * BaiduPushConstants.CHANNEL_REST_URL); pushClient.setChannelLogHandler(new
	 * YunLogHandler() {
	 * 
	 * @Override public void onHandle(YunLogEvent event) {
	 * System.out.println(event.getMessage()); } });
	 * 
	 * SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); JSONObject
	 * notification = new JSONObject(); notification.put("title", title);
	 * notification.put("description",content);
	 * notification.put("notification_builder_id", 0);
	 * notification.put("notification_basic_style", 4); JSONObject
	 * jsonCustormCont = new JSONObject(); //添加推送时间
	 * jsonCustormCont.put("time",sdf.format(new Date()) ); //自定义内容，key-value
	 * notification.put("custom_content", jsonCustormCont);
	 * 
	 * try { PushMsgToAllRequest request = new
	 * PushMsgToAllRequest().addMsgExpires(new Integer(3600*24*7))
	 * .addMessageType(1) .addMessage(notification.toString())
	 * .addDeviceType(3);
	 * 
	 * PushMsgToAllResponse response = pushClient.pushMsgToAll(request);
	 * System.out.println("msgId: " + response.getMsgId() + ",sendTime: " +
	 * response.getSendTime() + ",timerId: " + response.getTimerId()); } catch
	 * (PushClientException e) { if (BaiduPushConstants.ERROROPTTYPE) { } else {
	 * e.printStackTrace(); } } catch (PushServerException e) { if
	 * (BaiduPushConstants.ERROROPTTYPE) { } else {
	 * System.out.println(String.format(
	 * "requestId: %d, errorCode: %d, errorMessage: %s", e.getRequestId(),
	 * e.getErrorCode(), e.getErrorMsg())); } } }
	 */

}
